#
# packet template
#
# Copyright (C) 2009 by chrisv <me@cv.gd>
#          
# See CREDITS for details about who has contributed to this project.
#
# For further information about the pdaXrom project and license conditions
# see the README file.
#

SMBCLIENT_VERSION=3.3.4
SAMBA=samba-${SMBCLIENT_VERSION}.tar.gz
SMBCLIENT=smbclient-${SMBCLIENT_VERSION}.tar.gz
SMBCLIENT_MIRROR=http://us1.samba.org/samba/ftp
SMBCLIENT_DIR=$BUILD_DIR/samba-${SMBCLIENT_VERSION}
SMBCLIENT_ENV="$CROSS_ENV_AC"

build_smbclient() {
    test -e "$STATE_DIR/smbclient.installed" && return
    banner "Build smbclient"
    download $SMBCLIENT_MIRROR $SAMBA
    extract $SAMBA
    apply_patches $SMBCLIENT_DIR $SAMBA
    pushd $TOP_DIR

    cd $SMBCLIENT_DIR/source
    (
    eval \
	$CROSS_CONF_ENV \
	$SMBCLIENT_ENV \
	./configure --build=$BUILD_ARCH --host=$TARGET_ARCH \
	    --prefix=/usr \
	    --sysconfdir=/etc \
	    --with-libiconv=$TARGET_LIB \
	    || error
    ) || error "configure"
    
    make $MAKEARGS libsmbclient || error
    make $MAKEARGS bin/smbclient || error

    make DESTDIR=$TARGET_BIN_DIR installlibsmbclient
        
    TARGET_LIB=$SMBCLIENT_DIR/source/bin
    cd $TARGET_LIB
    for lib in libsmbclient.so.0 libtalloc.so.1 libtdb.so.1 libwbclient.so.0; do    	
		$INSTALL -D -m 644 $lib $ROOTFS_DIR/usr/lib/$lib || error
		$STRIP $ROOTFS_DIR/usr/lib/$lib
		create_so_compat_links $ROOTFS_DIR/usr/lib/$lib
    done
    $INSTALL -D -m 755 smbclient $ROOTFS_DIR/usr/bin/$file || error
    
    popd
    touch "$STATE_DIR/smbclient.installed"
}

build_smbclient
